package com.mjr.webmanage.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Slf4j
//@Aspect
//@Component
public class MyAspect2 {

    @Before("execution(* com.mjr.webmanage.service.impl.DeptServiceImpl.*(..))")
    public void before(JoinPoint joinPoint) {
        log.info("========================================");
        // 1. 获取目标类名称
        String name = joinPoint.getTarget().getClass().getName();
        log.info("目标类名称：{}", name);

        // 2. 获取方法签名
        String methodName2 = joinPoint.getSignature().toString();
        log.info("方法签名：{}", methodName2);

        // 3. 获取方名
        String methodName = joinPoint.getSignature().getName();
        log.info("方法名：{}", methodName);
        // 4. 获取参数
        Object[] args = joinPoint.getArgs();
        for (Object arg : args) {
            log.info("参数：{}", arg);
        }
        log.info("========================================");
    }
}
